#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;
int n, m;
vector<vector<char>> vc;
vector<vector<bool>> vis;
vector<pair<int,int>> ex;
int rex[4] = {1, 0, -1, 0};
int rey[4] = {0, 1, 0, -1};
int ans = 0;
int k = 1e9;
void dfs(int x, int y, int count) {
    if (vc[x][y] == 'e') {
        bool vv=false;
        for(auto& e : ex )
        {
            if(e.first==x&&e.second==y){
                vv=true;
                break;
            }
        }
        if(!vv){
            ans++;
            ex.push_back({x,y});
        }
        k = min(k, count);
        return;
    }
    for (int i = 0; i < 4; i++) {
        int x1 = x + rex[i];
        int y1 = y + rey[i];
        if (x1 >= 0 && x1 < n && y1 >= 0 && y1 < m && !vis[x1][y1] &&
                vc[x1][y1] != '*') {
            vis[x1][y1] = true;
            dfs(x1, y1, count + 1);
            vis[x1][y1] = false;
        }
    }
}
int main() {
    cin >> n >> m;
    vc.resize(n, vector<char>(m));
    vis.resize(n, vector<bool>(m, false));
    int startx = 0, starty = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> vc[i][j];
            if (vc[i][j] == 'k') {
                startx = i;
                starty = j;
            }
        }
    }
    vis[startx][starty] = true;
    dfs(startx, starty, 0);
    if (ans) {
        cout << ans << " " << k << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}